package v1.chapter6.proxy;
/**
 * 静态代理
 * @author admin
 *
 */
public class ProxyTest2 {

	public static void main(String[] args) {
		UserDao target=new UserDao();
		UserDaoProxy proxy=new UserDaoProxy(target);
		proxy.save();
	}

}

interface IUserDao {
	void save();
}

class UserDao implements IUserDao {
	public void save() {
		System.out.println("----已经保存数据!----");
	}
}

class UserDaoProxy implements IUserDao {
	private IUserDao target;

	public UserDaoProxy(IUserDao target) {
		this.target = target;
	}

	public void save() {
		System.out.println("开始事务...");
		target.save();
		System.out.println("提交事务...");
	}
}